@extends('template.base')
@section('content')
<script language="javascript">
<!--

function CreateProvince() {

  var Primary =  $("#provinsi").val()

  if ((Primary == null) || (Primary == 0)) return;
  
  <?php 
  foreach($provinsi as $kota){ ?>
      if (Primary == {{$kota->provinsi_id}}) {

        var ProvState = new Array;
        ProvState[0] = new Option("Silahkan pilih");

        <?php
        $regional = DB::table('ref_regional')
                  ->where('regional_provinsi_id','=',$kota->provinsi_id)
                  ->get();
        $i=0;
        foreach($regional as $kota){?>
         ProvState[{{$i}}] = new Option("{{$kota->regional_name}}");
       <?php
       $i++;
        }
        ?>


      }
  <?php } ?>

  for (i=document.newforms.member_regional_name.options.length; i>0; i--) { 
  document.newforms.member_regional_name.options[i] = null;
  }

  for(i=0; i<ProvState.length; i++) {
  document.newforms.member_regional_name.options[i] = ProvState[i];
  }

  document.newforms.member_regional_name.options[0].selected = true;

}

//-->
</script>



<div class="btn-group btn-group-justified" style="margin-bottom:5px">
          <div class="btn-group">
                <a href="{{URL::to('/')}}"><button class="btn btn-success2 btn-md" >Beranda</button></a>
          </div>
          <div class="btn-group">
                <a href="{{URL::to('cekorder')}}"><button class="btn btn-success2 btn-md">Cek order</button></a>
          </div>
          <div class="btn-group">
                <button class="btn btn-success2 btn-md" >Cara order</button>
          </div>
          <div class="btn-group">
                <button class="btn btn-success2 btn-md" >Kontak kami</button>
          </div>
  </div>
 <script src="{{URL::to('js/jquery-1.10.2.js')}}"></script>
<script src="{{URL::to('js/jquery-ui.js')}}"></script>
<div class="container-home" style="margin-bottom:5px;">
<h2 align="center"><u>Daftar sebagai agen</u></h2><br>
       <div class="row" style="margin-top:10px; width:98%; margin-left:5px">
        <div class="col-lg-8 col-lg-offset-2">
        <label>Data referal</label>
        <hr id="hr1"> </hr>
        <form action="{{URL::to('/agenreg')}}" method="POST" name="newforms">
            <div class="row">
            <div class="col-lg-6" style="margin-left:25px; margin-right:-25px">
            ID agen referal <font color="red">*</font>
            </div>
            <div class="col-lg-6">
              <input type="text"  class="form-control" style="width:250px;height:30px" name="id_agen" id="txt_products" placeholder="ID agen ex:1" required/></input>
               <script>
                $(function () {
                      var categories = [
                       <?php foreach($agen as $agn){ ?>
                      "{{$agn->agen_id}}",
                       <?php } ?>
                      ];

                      $('#txt_products').autocomplete({
                          minLength: 0,
                          source: categories,
                          focus: function (event, ui) {
                              $("#txt_products").val(ui.item.label);
                              return false;
                          },
                          select: function (event, ui) {
                             <?php foreach($agen as $agn){ ?>
                             if (ui.item.label == "{{$agn->agen_id}}" )
                                  $("#txt_category").val( "{{$agn->agen_code}}");
                                  $("#txt_category2").val( "{{$agn->agen_code}}");
                            <?php } ?>
                          }
                      });
                  });
                </script>
                 

            </div>
            </div>
            <br>

            <div class="row">
            <div class="col-lg-6" style="margin-left:25px; margin-right:-25px">
            Kode agen
            </div>
            <div class="col-lg-6">
              <input type="text"  class="form-control" style="width:250px;height:30px" id="txt_category" disabled /></input>
              <input type="hidden" name="kode_agen" id="txt_category2" /></input>
            </div>
            </div>
            <br>

        <label>Data anda</label>
        <hr id="hr1"> </hr>

            <div class="row">
            <div class="col-lg-6" style="margin-left:25px; margin-right:-25px">
            Nama anda <font color="red">*</font>
            </div>
            <div class="col-lg-6">
              <input type="text"  class="form-control" name="member_name" style="width:250px;height:30px" placeholder="Nama"  required  /></input>
            </div>
            </div>
            <br>

            <div class="row">
            <div class="col-lg-6" style="margin-left:25px; margin-right:-25px">
            Alamat <font color="red">*</font>
            </div>
            <div class="col-lg-6">
              <textarea  class="form-control" name="member_address" style="width:250px;height:70px" placeholder="Alamat"  required  /></textarea>
            </div>
            </div>
           
            <br>


            <div class="row">
            <div class="col-lg-6" style="margin-left:25px; margin-right:-25px">
            Propinsi <font color="red">*</font>
            </div>
            <div class="col-lg-6">
              <select  class="form-control" name="member_provinsi_id" id="provinsi" onChange="CreateProvince()" style="width:250px;height:30px" required />
              <option value="">Silahkan pilih</option>
              <?php 
              foreach($provinsi as $kota){
                if($kota->provinsi_id==$kota->provinsi_id){
                  echo '<option value="'.$kota->provinsi_id.'" selected>'.$kota->provinsi_name.'</option>';
                }else{
                  echo '<option value="'.$kota->provinsi_id.'">'.$kota->provinsi_name.'</option>';
                }
              }
              ?>
              </select>
            </div>
            </div>
            <br>


            <div class="row">
            <div class="col-lg-6" style="margin-left:25px; margin-right:-25px">
            Kota / Kabupaten <font color="red">*</font>
            </div>
            <div class="col-lg-6">
              <select  class="form-control" name="member_regional_name" style="width:250px;height:30px" required />
              <option value="">Silahkan pilih</option>
             
              </select>
            </div>
            </div>
            <br>

            <div class="row">
            <div class="col-lg-6" style="margin-left:25px; margin-right:-25px">
            Nomor telepon / HP<font color="red">*</font>
            </div>
            <div class="col-lg-6">
              <input type="phone"  class="form-control" name="member_phone" style="width:250px;height:30px" placeholder="No Telefon"   required /></input>
            </div>
            </div>

            <br>

            <div class="row">
            <div class="col-lg-6" style="margin-left:25px; margin-right:-25px">
            Alamat email<font color="red">*</font>
            </div>
            <div class="col-lg-6">
              <input type="email"  class="form-control" name="member_email" style="width:250px;height:30px" placeholder="Email"   required /></input>
            </div>
            </div>
            <br>

            <hr id="hr2"> </hr>
            <input type="checkbox" name="tos" value="1" required></input>  Saya setuju dengan <font color="blue"><u>syarat dan ketentuan</u></font><span class="pull-right"><font color="red">* Data tidak boleh kosong</font></span>
            <br>
            <br>

            <p align="center"><button type="submit" class="btn btn-primary btn-md btn-block" style="width:190px">Daftar</button></p>

        </form>
        </div> 
        </div>
        </div>

          
   
          



@stop
@stop
     